import { defineStore } from 'pinia'
import { computed, ref, reactive } from 'vue'
import { RouteRecordRaw } from 'vue-router'
import {permissionRoutes} from '../router'
// https://pinia.vuejs.org/zh/core-concepts/
// 选项式
export const useCounterStore = defineStore('counter', {
    state: () => ({ count: 0 }),
    getters: {
        double: (state) => state.count * 2,
    },
    actions: {
        increment() {
            this.count++
        },
    },
})

// 组合式
export const useCounter1Store = defineStore('counter1', () => {
    const count = ref(0)
    const doubleCount = computed(() => count.value * 2)
    function increment() {
        count.value++
    }

    return { count, doubleCount, increment }
})


export const useMainRoutes = defineStore("mainRoutes", () => {

    const routes = reactive(permissionRoutes as RouteRecordRaw[])

    return { routes }

})